package com.yf.service.course.impl;

import com.yf.dao.course.ActivityDao;
import com.yf.dao.course.SignUpDao;
import com.yf.entity.course.ActivityEntity;
import com.yf.entity.course.SignUpEntity;
import com.yf.enums.PayStatusEnum;
import com.yf.service.course.ActivityService;
import com.yf.service.impl.BaseServiceImpl;
import com.yf.vo.ActivityVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 活动Service实现类
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Fri Oct 26 15:01:00 CST 2018
 */
@Service
public class ActivityServiceImpl extends BaseServiceImpl<ActivityEntity> implements ActivityService {
    @Autowired
    private ActivityDao activityDao;

    @Autowired
    private SignUpDao signUpDao;

    /**内部方法**/


    /**外部方法实现**/

    @Override
    public ActivityEntity getLast() {
        return activityDao.getLast();
    }

    @Override
    public List<ActivityEntity> getAll() {
        return activityDao.getAll();
    }

    @Override
    public List<ActivityVO> getBanner() {
        return activityDao.getBanner();
    }

    @Override
    public ActivityEntity getActivity(Long userId,Long activityId) {

        ActivityEntity activityEntity = activityDao.get(activityId);

        SignUpEntity signUpEntity = signUpDao.getByIdAndPayStatus(userId,activityId,PayStatusEnum.PAID.getState());

        if(signUpEntity!=null){
            activityEntity.setSignUp(true);
        }else {
            activityEntity.setSignUp(false);
        }


        return activityEntity;
    }
}
